package com.gxc.mall.user.controller;

import com.gxc.mall.common.util.RestControllerResult;
import com.gxc.mall.user.entity.UserEntity;
import com.gxc.mall.user.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author GongXincheng
 * @since 2019-09-07 17:48
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/{id}")
    public RestControllerResult<UserEntity> findUserById(@PathVariable Integer id) {
        UserEntity userEntity = userService.findUserById(id);
        return RestControllerResult.success(userEntity);
    }

    @PostMapping
    public RestControllerResult addUser(@RequestBody UserEntity userEntity) {
        userService.saveUser(userEntity);
        return RestControllerResult.success("insert user success !");
    }

}
